use std::{f64::consts::PI, vec};
fn main() {
    trait Shape {
        fn area(&self) -> f64;
    }
    struct Circle {
        radius: f64,
    }
    impl Shape for Circle {
        fn area(&self) -> f64 {
            self.radius * self.radius * PI
        }
    }

    struct Rectangle {
        width: f64,
        height: f64
    }

    impl Shape for Rectangle {
        fn area(&self) -> f64 {
            self.width * self.height
        }
    }

    let circle = Circle {radius: 50.0};
    let rectangle = Rectangle {width: 12.0, height: 12.0};
    let v:Vec<&dyn Shape> = vec![&circle, &rectangle];
    for item in v {
        let res = item.area();
        println!("the area: {}", res);
    }
}